import type { CommonNodeType, VarType, Variable } from '@/components/workflow/types'
import { QueryCondition, QueryExtention } from '@/services/local'

export enum Method {
  find = 'find',
  findone = 'findone',
  create = 'create',
  delete = 'delete',
  update = 'update',
}

export type Timeout = {
  connect?: number
  read?: number
  write?: number
  max_connect_timeout?: number
  max_read_timeout?: number
  max_write_timeout?: number
}

export type OutputVar = Record<string, {
  type: VarType
  children: null // support nest in the future,
}>

export type DataOperatorType = CommonNodeType & {
  domain: string,
  class: string,
  datasource: string,
  method: Method,
  conditions?: QueryCondition,
  extentions?: QueryExtention,
  value?: { [key: string]: any },
  options?: { [key: string]: any },
  outputs: OutputVar
}
